<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<input type="text" id="c" value=""/>
		<input type="button" id="a" value="开始" onclick="kaishi()" />
		<input type="button" id="b" value="停止" onclick="ting()" />
	</body>
	<script type="text/javascript">
		var timer;
		var i=0;
		function kaishi(){
			document.getElementById("c").value=i;
			i+=1;
			timer = setTimeout("kaishi()",100)
		}
		
		function ting(){
			clearTimeout(timer);
		}
	</script>
</html>
